#ifndef PREPARE_STATEMENT_H
#define PREPARE_STATEMENT_H

#include "table.h"
#include "read_buffer.h"
typedef enum
{
    PREPARE_SUCCESS,
    PREPARE_SYNTAX_ERROR, // 解析错误
    PREPARE_UNRECOGNIZED_STATEMENT,
    PREPARE_STRING_TOO_LONG, // 参数太长
    PREPARE_NEGATIVE_ID, //负数id
} PrepareResult;

typedef enum
{
    STATEMENT_INSERT,
    STATEMENT_SELECT
} StateType;

typedef struct
{
    StateType state_type;
    Row row_to_insert; // 只有在插入的时候
} Statement;

// 处理指令
PrepareResult prepare_statement(InputBuffer *input_buffer, Statement *statement);

PrepareResult prepare_insert(InputBuffer *input_buffer, Statement *statement);

// 序列化row  将row写入内存
void serialize_row(Row *source, void *destination);
// 反序列化  将内存里的row读出来
void deserialize_row(void *source, Row *destination);

// 返回table[row_num]
void *row_slot(Table *table, uint32_t row_num);

#endif // PREPARE_STATEMENT_H